#include <jni.h>
#include <stdio.h>

JNIEXPORT jbyteArray JNICALL
Java_tw_zld369504_wol_utils_PacketUtil_getWakeUpPacket(JNIEnv *env, jobject instance,
                                                 jbyteArray macData_) {
    jsize length = (*env)->GetArrayLength(env, macData_);//c
    jbyte *t1 = (*env)->GetByteArrayElements(env, macData_, NULL);//c
    jbyteArray returnArray = (*env)->NewByteArray(env, length * 17);//java
    jbyte sampleMac[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
    int loop = 0;
    for (loop = 0; loop < 17; loop++) {
        if (loop == 0)
            (*env)->SetByteArrayRegion(env, returnArray, loop, 6, sampleMac);
        else
            (*env)->SetByteArrayRegion(env, returnArray, loop * length, length, t1);
    }
    (*env)->ReleaseByteArrayElements(env, macData_, t1, 0);
    return returnArray;
}